package edu.uwm.capstone.diasmart;

import edu.uwm.capstone.diasmart.util.AddEntryHelper;
import edu.uwm.capstone.util.DebugUtil;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/**The main file to be launched on installation of the diasmart app
 * */
public class MainActivity extends Activity {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button btnAdd = (Button) findViewById(R.id.btnAdd);
		Button btnSettings = (Button)findViewById(R.id.btnSettings);
		
		btnAdd.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				//MainActivity.this.startActivity(new Intent(MainActivity.this,AddEditEntryActivity.class));
				if("add".equals(AddEntryHelper.getAddPreferenceType(MainActivity.this)))
				{
					DebugUtil.debug("Diasmart", "Preference type values " + AddEntryHelper.getAddPreferenceType(MainActivity.this));
					AddEntryHelper.showAddDialog(MainActivity.this);
				}
					
			}
		});
		
		btnSettings.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				MainActivity.this.startActivityForResult(new Intent(MainActivity.this,EditPreferencesActivity.class), 1);
				
			}
		});
		

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
